cmake_minimum_required(VERSION 3.6)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
project(LeetCode)

set(CMAKE_CXX_STANDARD 11)


ExternalProject_Add(googletest
        PREFIX ${CMAKE_CURRENT_BINARY_DIR}/googletest
        SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/googletest
)

function(add_answer_test)
    foreach(GT ${ARGN})
        add_executable(${GT} ${GT}.cpp)
        add_dependencies(${GT} googletest)
        target_include_directories(${GT} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/googletest/include)
        target_link_libraries(${GT} ${CMAKE_CURRENT_BINARY_DIR}/googletest/lib/libgtest.a)
    endforeach()
endfunction()

add_answer_test(TwoSum AddTwoNumbers
        LongestSubstring
        ReverseInteger
        FindDisappearedNumbers
)
